<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" id="input">
  <script>
    let data = {
      name: 'GG'
    }
    let data2 = ''
    Object.defineProperty(data, 'name', {
      get() {
        console.log('GG被调用了')
        return data2
      },
      set(val) {
        console.log('GG被修改了')
        console.log('修改之后的值是', val)

        document.getElementById('input').value = val
        data2 = val
      }
    })
    document.querySelector('#input').addEventListener('input', (e) => {
      data.name = e.target.value
    })
  </script>
</body>

</html>